사용자 삽입 이미지

대인배는 1~3과, 4~6과... 이런식으로 따로 구하지 않습니다.

줌달 일반화학 제7판 쏠루션 풀버전입니다. 알집으로 압축풀면 됨.

동생들아 잘 쓰세요. 졸업하는 형아의 선물입니다.

Posted by 정훈승
#include <windows.h>

#define DIVISIONS 5

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR  szCmdLine, int iCmdShow)
{
     static TCHAR szAppName[] = TEXT ("Checker1") ;
     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;
    
     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = NULL ;
     wndclass.lpszClassName = szAppName ;
    
     if (!RegisterClass (&wndclass))
     {
          MessageBox (NULL, TEXT ("Program requires Windows NT!"),
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }
    
     hwnd = CreateWindow (szAppName, TEXT ("Checker1 Mouse Hit-Test Demo"),
                          WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          NULL, NULL, hInstance, NULL) ;
    
     ShowWindow (hwnd, iCmdShow) ;
     UpdateWindow (hwnd) ;
    
     while (GetMessage (&msg, NULL, 0, 0))
     {
          TranslateMessage (&msg) ;
          DispatchMessage (&msg) ;
     }
     return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static int  fState[DIVISIONS][DIVISIONS] ;
     static int  cxBlock, cyBlock, Counting ;
     HDC         hdc ;
     int         x, y ;
     PAINTSTRUCT ps ;
     RECT        rect ;
    
     switch (message)
     {

     case WM_SIZE :
          Counting = 3 ;
          cxBlock = LOWORD (lParam) / DIVISIONS ;
          cyBlock = HIWORD (lParam) / DIVISIONS ;
          return 0 ;
         
     case WM_LBUTTONDOWN :
          Counting++;
          x = LOWORD (lParam) / cxBlock ;
          y = HIWORD (lParam) / cyBlock ;
         
          if (x < DIVISIONS && y < DIVISIONS && !fState [x][y])
          {
               switch(Counting%2)
               {
               case 0 :
                   fState [x][y] ^= 1 ; break;
               case 1:
                   fState [x][y] ^= 2 ; break;
               }

               rect.left   = x * cxBlock ;
               rect.top    = y * cyBlock ;
               rect.right  = (x + 1) * cxBlock ;
               rect.bottom = (y + 1) * cyBlock ;
              
               InvalidateRect (hwnd, &rect, FALSE) ;
          }
          else
               MessageBeep (0) ;
          return 0 ;
         
     case WM_PAINT :
          hdc = BeginPaint (hwnd, &ps) ;
         
          for (x = 0 ; x < DIVISIONS ; x++)
          for (y = 0 ; y < DIVISIONS ; y++)
          {
               Rectangle (hdc, x * cxBlock, y * cyBlock,
                         (x + 1) * cxBlock, (y + 1) * cyBlock) ;
                   
               if (fState [x][y] == 1)
               {
                    MoveToEx (hdc,  x * cxBlock,  y * cyBlock, NULL) ;
                    LineTo   (hdc, (x+1) * cxBlock, (y+1) * cyBlock) ;
                    MoveToEx (hdc,  x * cxBlock, (y+1) * cyBlock, NULL) ;
                    LineTo   (hdc, (x+1) * cxBlock,  y * cyBlock) ;
               }
               if (fState [x][y] == 2)
               {
                    Ellipse (hdc, x * cxBlock, y * cyBlock,
                         (x + 1) * cxBlock, (y + 1) * cyBlock) ;
               }
          }
          EndPaint (hwnd, &ps) ;
          return 0 ;
              
     case WM_DESTROY :
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}



기존 소스는 동그라미만 그려진다.
이 소스가 오델로 게임의 베이스라나...뭐래나....

첫번째 수정은,
한번 그려진 네모칸에는 더이상 그려지지 않고

두번째 수정은,
한번은 동그라미, 한번은 엑스표가 그려지게 하였다.

칸수를 더 늘리고
엑스표를 검은색 동그라미로 바꾸고
오델로 규칙을 적용하면, 오델로 게임이 완성되겠지?
Posted by 정훈승
INCLUDE Irvine32.inc

.data
loopsize = 5 ;c++의 DEFINE
arr BYTE loopsize DUP(?) ;배열선언
str1 BYTE "Enter 5 numbers : ", 0
str2 BYTE "Reverse 5 numbers : ", 0
str3 BYTE ". ", 0

.code
main PROC
    mov esi, OFFSET arr
    mov edx, OFFSET str1
    call WriteString ;c++의 cout
    call Crlf ;c++의 \n

    mov ecx, loopsize ;루트를 몇번 돌릴지
L1:

    call ReadInt ;c++의 cin
    push eax
    inc esi ;c++의 증가연산자(++)
    loop L1
    call Crlf
    mov edx, OFFSET str2
    call WriteString

    mov ecx, loopsize
    mov edx, OFFSET str3
L2:
    pop eax
    call WriteDec
    call WriteString
    loop L2
    call Crlf

    exit

main ENDP
END main

어셈블리 언어에서 스택은 push명령어와 pop명령어로 이루어져있다.
5개의 숫자를 입력받아서 거꾸로 출력되는 프로그램이다.

c++에서는 입력된 숫자의 개수를 자동으로 알아낼 수 있지만
어셈블리에서는 어떤 방법이 있을까?

흠...곧 알아낼 것이다.
Posted by 정훈승
INCLUDE Irvine32.inc

CHAR_VALUE = '!';

.code
main PROC
    call Clrscr
    mov eax, 0

    mov ecx, 16
L1:
    push ecx ;vary the background colors

    mov ecx, 16
L2:
    SetTextColor ;vary the foreground colors
    push eax
    mov al, CHAR_VALUE
    call WriteChar
    pop eax

    inc al ;next foreground color
    loop L2

    sub al, 16 ;reset forground color to zero
    add al, 16 ;select next backtround color
    call Crlf

    pop ecx
    loop L1

    mov eax, 7
    call SetTextColor

    exit
main ENDP
END main

문자를 모든 가능한 전경색과 배경색의 조합(16*16=256)으로 출력하는 프로그램
색상은 0부터 15까지의 번호가 부여되어서 모든 가능한 조합을 생성하기 위해서 중첩된 루프를 사용할 수 있다
Posted by 정훈승
INCLUDE Irvine32.inc

STR_COUNT = 20
STR_SIZE = 10

.data
aString BYTE STR_SIZE DUP(0), 0

.code
main PROC
    mov ecx, STR_COUNT ;outer loop count

L1:
    push ecx ;save outer loop count

    ;generate a single string
    mov ecx, STR_SIZE ;loop counter
    mov esi, OFFSET aString ;string index

L2:
    mov eax, 26 ;generate random int 0~25
    cal RandomRange
    add eax, 'A' ;range A~Z
    mov [esi], al ;store the character
    inc esi ;next character position
    loop L2

    mov edx, OFFSET aString ;dispay the string
    call WriteString
    call Crlf

    pop ecx ;restore outer loop count
    loop L1 ;repeat outer loop

    exit
main ENDP
END main

A부터 Z까지 중에서 10개의 대문자로 구성되는 20개의 임의의 문자열을 생성하여 표시하는 프로그램
Posted by 정훈승
INCLUDE Irvine32.inc

.data
aName BYTE 10, 20, 30, 40, 50
nameSize = ($ - aName)


.code
main PROC
    mov ecx, nameSize ;리스트 길이만큼 루프 돌린다
    mov esi, 0 ;스택에 리스트 삽입
L1:
    movzx eax, aName[esi] ;리스트 얻는다
    push eax ;스택을 민다
    inc esi ;esi + 1
    loop L1

    mov ecx, nameSize ;다시 루프횟수 설정
    mov esi, 0

L2:
    pop eax ;리스트 얻는다
    mov aName[esi], al
    inc esi

    mov edx, OFFSET aName
    call WriteDec ;리스트출력
    loop L2
    exit

main ENDP
END main

말그대로 숫자 거꾸로 출력하기
Posted by 정훈승
INCLUDE Irvine32.inc

.data
aName BYTE "Hoonseung Jeong", 0
nameSize = ($ - aName) - 1
;마지막에 0은 빼줌

.code
main PROC
    mov ecx, nameSize ;문자열 길이만큼 루프 돌린다
    mov esi, 0 ;스택에 문자열 삽입
L1:
    movzx eax, aName[esi] ;문자열 얻는다
    push eax ;스택을 민다
    inc esi ;esi + 1
    loop L1

    mov ecx, nameSize ;다시 루프횟수 설정
    mov esi, 0

L2:
    pop eax ;문자열 얻는다
    mov aName[esi], al
    inc esi
    loop L2

    mov edx, OFFSET aName
    call WriteString ;문자열출력
    call Crlf ;c++의 \n과 같음
    exit

main ENDP
END main

그냥 말 그대로 문자열 거꾸로
Posted by 정훈승



원, 네모, 선 그리기 과제입니다.
타입을 선택할 수 없으며, 순서대로 그려집니다.
스페이스를 누르면 초기화됩니다.

Counting이라는 변수를 스태틱으로 선언해주고 초기값을 3으로 줍니다.
마우스를 한번 누를때마다 Counting이 1씩 올라갑니다.
Counting++

Counting을 3으로 나눠준 몫의 나머지로 어떤 타입으로 그릴지 정해줍니다.
Switch(Counting%3)

0은 원, 1은 네모, 2는 선

참~~~ 쉽쬬잉
Posted by 정훈승
Ferris was given credit for the success of the Chicago World's Fair.
페리스는 시카고 세계박람회로부터 공로를 받았다.

His wheel was not only a technological marvel, but a thing of beauty.
그의 휠은 기술적으로도 놀라울뿐만 아니라, 아름다운 것이었다.

In fact, the fair's organizers worried that Ferris might have done his job too well.
사실, 주최측은 걱정했다 페리스가 그의 직업이 너무 잘되서.

The Ferris Wheel seemed too light, too delicate to support itself.
페리스휠은 스스로 지탱하기에는 너무 가볍고, 너무 섬세해보였다.

History records, however, that the only dangers connected to the Ferris wheel came from passengers themselves.
역사는 기록한다, 하지만, 페리스휠의 유일한 위험한 점은 승객들 자신과 연결되어 있다.

One passenger, a man named Wherritt, panicked as the wheel began to rotate upwawrd.
한 승객이, 웨리트라고 불리는 놈, 휠이 위를 향해 움직이기 시작하자 겁을 먹었다.

He violently crashed around the car until a woman cleverly removed her skirt and threw it over his head.
그는 격렬하게 객실 주위를 쳐댔다 한 여성이 영리하게 자신의 치마를 벗어서 그의 머리를 덮어버릴때까지.

He instantly calmed down.
그는 곧바로 진정했다.

She spoke softly and gently to him until the car returned to the ground and he was helped out.
그녀는 그에게 부드롭고 예의있게 말했다 객실이 땅으로 돌아올때까지 그리고 그는 도움을 받아서 나갔다.

The influence of Ferris's engineering and entertainment marvel is still clear today.
페리스의 기술과 오락적 놀라움의 영향은 오늘날에도 명백하다.

In 1999, London, England, continued the tradition of marking momentous occations by erecting a Ferris wheel.
1999년, 런던, 영국, 페리스휠과 같이 중요한 행사에 돋보이게 하는 전통을 이어나갔다.

The London Eye, the largest Ferris wheel in the world, was built to celebrate the beginning of the new millennuim.
런던 눈깔, 세계에서 가장 큰 페리스휠, 새로운 천년을 기념하기 위해 지어졌다.

On a smaller scale, Ferris wheels of various size and type are attractions at fairs and amusement parks around the world.
좀 작은 범위로, 다양한 사이즈와 종류의 페리스휠은 박람회와 전세계적인 놀이공원의 매력이다.

More than a century after it first dezzled visitor at the Chicago World's Fair, the Ferris wheel still has the power to fascinate, thrill, and amaze.
페리스휠이 시카고 세계박람회에서 방문객들을 감탄시킨지 100년 이상이 지났다, 페리스휠은 여전히 매혹적이고 스릴있고 놀라운 힘을 가졌다.
Posted by 정훈승


흔히들 '정보통신' 이라는 과목으로 듣는 수업

고려대학교 컴퓨터정보학과 2학기 과목

Data Cimmunications and Networking Solution

정보통신 솔루션


p.s
정작 나는 이 수업 안들음 ㅋㅋㅋ
Posted by 정훈승