Bill (18.07.2012 18:35, просмотров: 75) ответил alex68 на Жаль, что исходники ОС у меня на ленте, которую уже негде прочесть, и на бумаге, которую долго сканировать. А то я вам бы скинул их и вы бы глянули, как в 75-76 году писали на ассемблере (может и позже, но там копирайт именно этих лет). Это
Маленький пример
;+
; ** GETCC - READ IN A CHARACTER CONSTANT
;
; READ A CHARACTER CONSTANT INTO VAL1. THIS ROUTINE IS SENSITIVE TO
; THE ORDER OF CHARACTERS IN A WORD (IN THE PDP-11, UNLIKE THE VAST
; MAJORITY OF MACHINES, THIS IS RIGHT TO LEFT).
;
; A DIAGNOSTIC IS GENERATED IF THE CHARACTER CONSTANT ENDS SUDDENLY,
; OR CONTAINS TOO MANY (>2) CHARACTERS.
;
; USES:
; R0, R1, R2
;-
GETCC: MOV #VAL1,R2 ;POINT AT RETURN AREA
CLR (R2) ;INITIALIZE TO ZERO
MOV #'',R1 ;SET UP DELIMITER FOR MAPCH
10$: CALL MAPCH ;GET CHARACTER FROM INPUT
BCS 30$ ;BR IF END OF CONSTANT
CMP R2,#VAL1+2 ;TEST IF TOO MANY CHARACTERS
BHIS 20$ ;BR IF YES
MOVB R0,(R2) ;OTHERWISE SAVE THE CHARACTER
20$: INC R2 ;IN ANY CASE, ADVANCE THE POINTER
BR 10$ ;AND CONTINUE
30$: CMP R2,#VAL1+2 ;WERE THERE TOO MANY CHARACTERS?
BLOS 40$ ;BR IF NOT
MOV #ERR04,R0 ;IF TOO MANY CHARACTERS
CALL ERROR1 ;COMPLAIN ;01
40$: RETURN ;
;+
; ** GETNAM - READ AN IDENTIFIER INTO NB
;
; THIS ROUTINE READS THE FIRST 8. CHARACTERS INTO NB. IF THE
; IDENTIFIER IS TOO LONG THE EXTRA CHARACTERS ARE DISCARDED.
;
; CHARACTERS ARE CLASSIFIED BY LOOKING IN THE JUMP TABLE
; FOR ADDRESSES ADV85 (NUMERICS) AND ADV155 (ALPHABETICS).
; THIS IS FAIRLY DIRTY, BUT WILL PROBABLY REMAIN.
;
; USES:
; R0, R1, R2
;-
GETNAM: MOV #NB,R1 ;POINT AT THE NAME BUFFER
10$: MOV R0,R2 ;CLASSIFY THE CHARACTER
ASL R2
MOV ADVTAB(R2),R2
CMP R2,#ADV85 ;NUMERIC (0 TO 9)
BEQ 20$ ;YES
CMP R2,#ADV155 ;ALPHABETIC (A TO Z, a TO z, _, $)
BNE 40$ ;NO, END OF IDENTIFIER
CMP R0,#'$ ;HACK, $ -> TILDE ;02+
BNE 20$ ;NO HACK TODAY
MOV #176,R0 ;YES, FIX IT UP ;02-
20$: CMP R1,#NB+8. ;IF THE CHARACTER FITS
BHIS 30$
MOVB R0,(R1)+ ;SAVE IT IN THE BUFFER
30$: CALL GETC ;GRAB THE NEXT CHARACTER, AND
BCC 10$ ;CONTINUE
BR 50$ ;END OF FILE DELIMITED IDENTIFIER
40$: CALL UNGETC ;PUT LAST (BAD) CHARACTER BACK
50$: CLRB (R1) ;TERMINATE THE STRING ;07
RETURN